JavaScript: scroll position (Webkit engine) [migrated]

Posted by Julien on Pro Webmasters See other posts from Pro Webmasters or by Julien
Published on 2011-11-22T02:44:44Z Indexed on 2011/11/22 10:28 UTC
Read the original article Hit count: 183

Filed under:

I'm currently trying to use JavaScript to find out how far down the page the user has scrolled; for Firefox 8.0, the keyword is pageYOffset.

To say things mechanically:

  1. The page has a certain height. In Firefox, the useful object is document.documentElement.scrollHeight.

  2. The browser's visible area also has a certain height. In Firefox, the object is window.innerHeight; in IE8, document.documentElement.clientHeight.

  3. I need to know where the user is in the page vertically; in other words, how many pixels down the page the user has scrolled.

Does Webkit have a DOM object that refers to the current scroll position?

Thank you.

© Pro Webmasters or respective owner

Related posts about JavaScript